const httpRequest = require("@/common/httpRequest.js")
import App from './App'
const copy = (value) => { //复制
	console.log("复制");
	uni.setClipboardData({
		data: value, //要被复制的内容
		success: () => {
			//复制成功的回调函数
			httpRequest.toast("复制成功")
		}
	});
}
const lbtpriview = (index, arr) => { //预览图片
	console.log("预览图片");
	var i = arr; //获取当前页面的轮播图数据
	//uniapp预览轮播图
	uni.previewImage({
		current: index, //预览图片的下标
		urls: i //预览图片的地址，必须要数组形式，如果不是数组形式就转换成数组形式就可以
	})
}
const callphone = (p) => { //拨打电话
	console.log("拨打电话");
	uni.makePhoneCall({
		phoneNumber: p.toString()
	}).catch((e) => {
		// console.log(e)  //用catch(e)来捕获错误{makePhoneCall:fail cancel}
	})
}
const returnKmUnit = (m) => {
	var v;
	if (typeof m === 'number' && !isNaN(m)) {
		if (m >= 1000) {
			v = (m / 1000).toFixed(2) + 'km'
		} else {
			v = m + 'm'
		}
	} else {
		v = '0m'
	}
	return v;
}
const jumpdetail = (url, val) => {
	uni.navigateTo({
		url: url + val
	})
}
const lbtclick = (e, val) => { //点击轮播图
	console.log("点击轮播图");
	if (val[e].url) {
		uni.navigateTo({
			url: val[e].url
		})
	}
}

// #ifndef VUE3
import Vue from 'vue'
import './uni.promisify.adaptor'
Vue.config.productionTip = false
Vue.prototype.copy = copy
Vue.prototype.lbtpriview = lbtpriview
Vue.prototype.callphone = callphone
Vue.prototype.returnKmUnit = returnKmUnit
Vue.prototype.lbtclick = lbtclick
Vue.prototype.jumpdetail = jumpdetail


App.mpType = 'app'
const app = new Vue({
	...App
})
app.$mount()
// #endif

// #ifdef VUE3
import {
	createSSRApp
} from 'vue'
export function createApp() {
	const app = createSSRApp(App)
	return {
		app
	}
}
// #endif
// main.js
import uView from "uview-ui";
Vue.use(uView);